package cn.dujy.derby.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * <p>
 * Swagger2 配置
 * </p>
 * @since 2023-12-06
 * @author 杜家源
 */
/*注明配置*/
@Configuration
/*开启Swagger2*/
@EnableSwagger2
public class Swagger2Config {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("cn.dujy.derby.web.rest"))
                .paths(PathSelectors.any())
                .build();
    }


    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("【pretty_derby】服务api文档平台")
                .contact(new Contact("杜家源", "url", "dujy1024@outlook.com"))
                .version("1.0")
                .description("【pretty_derby】服务API描述")
                .build();
    }

    /**Spring Security - 配置免认证访问**/
    /*1、先去放行*/

    /*2、下面*/
//    private ApiKey apiKey(){
//        return new ApiKey("JWT","Authorization","header");
//    }
//
//    private SecurityContext securityContext(){
//        return SecurityContext.builder().securityReferences(defaultAuth()).build();
//    }


}
